%% this code aims to plot each trial and average data.
s = 1;%% starting trial;
e = 10;%% ending trial;
block_name =1;%% the name of saved data;
fs = 2000; %% sampling rate.
L = 3001; %% time interval.
n = 8; %% n muscle.
average_data_name = 1; %% choose the average_data.
%% create time vector.
for i = 1:L
time(i,1) = i / fs;
end
%% choose the average_data.
average_filename = sprintf('/Users/chenzhi/cz.ongoing/AOP_conference/block_average/%d_average_data.csv',1);
data = importdata(average_filename)%% data name;
for j = 1:n
subplot(n,1,j)
    for i = s:e
    filename = sprintf('/Users/chenzhi/cz.ongoing/AOP_conference/aligned_data/%d_aligned_data.csv',i);
    raw_data = importdata(filename)
    plot(time,raw_data(:,n),'color',[0.5 0.54 0.53]);
    ylim([0 inf])
    hold on 
end
plot(time,data(:,j),'color','r','linewidth',2)
hold off
end

    

